FROM openshift/base-centos7

VOLUME /work
WORKDIR /work
COPY ./requirements.txt ./Python-3.7.0.tar.xz ./*.rpm /work/


RUN yum-config-manager --add-repo https://download.opensuse.org/repositories/home:/Alexander_Pozdnyakov/CentOS_7/ && \
    yum -y update && yum -y groupinstall "Development tools" && \

    yum -y install libffi-devel && \
    yum -y install leptonica-1.76.0-2.3.x86_64.rpm leptonica-devel-1.76.0-2.3.x86_64.rpm && \

    yum -y install tesseract-4.0.0+git3834-1.1.x86_64.rpm tesseract-langpack-eng-4.00_git30-5.2.noarch.rpm tesseract-langpack-osd-4.00_git30-5.2.noarch.rpm && \
    yum -y install tesseract-devel-4.0.0+git3834-1.1.x86_64.rpm && \

    yum -y install tesseract-langpack-chi-sim-4.00_git30-5.2.noarch.rpm && \
    yum -y install tesseract-langpack-deu-4.00_git30-5.2.noarch.rpm && \
    
    yum -y install tesseract-langpack-deu tesseract-langpack-chi-sim && \
    echo 'alias shasum="sha1sum"' >> ~/.bashrc && \
    tar xvJf Python-3.7.0.tar.xz && rm Python-3.7.0.tar.xz && \
    cd ./Python-3.7.0 && \
    ./configure --prefix=/usr/local LDFLAGS="-Wl,-rpath /usr/local/lib" --with-ensurepip=install && \
    make && make altinstall && \
    yum clean all && \
    ln -s /usr/local/bin/pip3.7 /usr/local/bin/pip3 && \
    ln -s /usr/local/bin/python3.7 /usr/local/bin/python3 && \
    localedef -c -i en_US -f UTF-8 en_US.UTF-8

ENV PYTHON_VERSION=3.7.0 \
    PATH=$HOME/.local/bin/;$PATH \
    PYTHONUNBUFFERED=1 \
    PYTHONIOENCODING=UTF-8 \
    # LC_ALL=en_us.UTF-8 \
    LC_CTYPE=en_us \
    LANG=en_us.UTF-8 \
    APP_HOME=/work

RUN pip3 install -r requirements.txt -i https://pypi.mirrors.ustc.edu.cn/simple

CMD ['bash']
